<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>lodash实现深拷贝</title>
</head>

<body>
    <script src="./Lodash/lodash.min.js"></script>
    <script>
        const person = {
            name: '李四',
            age: 18,
            hobby: ['篮球', '游戏'],
            family: {
                dad: '老四',
                mom: '翠花'
            }
        }

        const per = _.cloneDeep(person)
        per.hobby.push('rap')
        per.family.dad = '老六'
        console.log(per); // {name: '李四', age: 18, hobby:['篮球', '游戏', 'rap'], family: {{dad: '老六', mom: '翠花'}}
        console.log(person); // {name: '李四', age: 18, hobby:['篮球', '游戏'], family: {{dad: '老四', mom: '翠花'}}
    </script>
</body>

</html>